﻿CREATE TABLE [dbo].[Lead] (
    [LeadId]            UNIQUEIDENTIFIER NOT NULL,
    [LeadSourceCode]    INT              NULL,
    [PriorityCode]      INT              NULL,
    [Subject]           NVARCHAR (300)   NULL,
    [Description]       NVARCHAR (MAX)   NULL,
    [CompanyName]       NVARCHAR (100)   NULL,
    [FirstName]         NVARCHAR (50)    NULL,
    [MiddleName]        NVARCHAR (50)    NULL,
    [LastName]          NVARCHAR (50)    NULL,
    [Revenue]           MONEY            NULL,
    [NumberOfEmployees] NCHAR (10)       NULL,
    [EmailAddress]      NVARCHAR (100)   NULL,
    [FullName]          NVARCHAR (160)   NULL,
    [WebSiteUrl]        NVARCHAR (200)   NULL,
    [MobilePhone]       NVARCHAR (50)    NULL,
    [Telephone1]        NVARCHAR (50)    NULL,
    [Telephone2]        NVARCHAR (50)    NULL,
    [Fax]               NVARCHAR (50)    NULL,
    [CreatedOn]         DATETIME         NULL,
    [ModifiedOn]        DATETIME         NULL,
    [StatusCode]        INT              NULL,
    [VersionNumber]     ROWVERSION       NULL,
    [CustomerId]        UNIQUEIDENTIFIER NULL,
    [OwnerId]           UNIQUEIDENTIFIER NULL,
    [Country]           NVARCHAR (100)   NULL,
    [City]              NVARCHAR (100)   NULL,
    [Address]           NVARCHAR (100)   NULL,
    [ZIP]               NVARCHAR (50)    NULL,
    [DepartmentId]      UNIQUEIDENTIFIER NULL,
    [OriginalMessage]   NVARCHAR (200)   NULL,
    [IsDeleted]         BIT              CONSTRAINT [DF_Lead_IsDeleted] DEFAULT ((0)) NOT NULL,
    [ModifiedById]      UNIQUEIDENTIFIER NULL,
    [CreatedById]       UNIQUEIDENTIFIER NULL,
    [CountryCode]       INT              NULL,
    [TechnologyCode]    INT              NULL,
    CONSTRAINT [PK_Lead] PRIMARY KEY CLUSTERED ([LeadId] ASC),
    CONSTRAINT [FK_Lead_Department] FOREIGN KEY ([DepartmentId]) REFERENCES [dbo].[Department] ([DepartmentId]),
    CONSTRAINT [FK_Lead_User] FOREIGN KEY ([OwnerId]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_Lead_User_CreatedBy] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_Lead_User_ModifiedBy] FOREIGN KEY ([ModifiedById]) REFERENCES [dbo].[User] ([UserId])
);



